home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / snmp_0_1.zip / snmp-0.1 / aka / snmp / MibManagerParser.java < prev    next >
Text File  |  1997-06-09  |  2KB  |  87 lines

  1. /*
  2. Snmp Library
  3. Copyright (C) 1997 Alex Kowalenko Associates Pty Ltd. All rights reserved.
  4.  
  5. $Id: MibManagerParser.java,v 1.2 1997/06/05 11:59:22 alex Exp $
  6.  
  7. This software maybe be free distributed, any any form, without fee, 
  8. but may not be modified in any way without express permission of 
  9. the directors of Alex Kowalenko Associates Pty Ltd. 
  10.  
  11. Alex Kowalenko Associates Pty Ltd makes no representations or
  12. warranties about the suitabililty of the software, not even the
  13. implied warranty of merchantability or fitness for any particular
  14. purpose.    
  15. */
  16.  
  17. package aka.snmp;
  18.  
  19. import aka.mc.*;
  20. import java.util.*;
  21. import java.io.*;
  22.  
  23. /**
  24.  * Extends MibManager with the managed object compiler.
  25.  * @see MibManager
  26.  * @version     $Id: MibManagerParser.java,v 1.2 1997/06/05 11:59:22 alex Exp $
  27.  * @author      Alex Kowalenko
  28.  */
  29.  
  30. public class MibManagerParser extends MibManager {
  31.  
  32. /**
  33.  * Constructor
  34.  */
  35.  
  36.   public MibManagerParser() {
  37.       super();
  38.   };
  39.   
  40.  
  41. /** 
  42.  * Read MIB defintions from MIB file.  This file is parse and SNMP Object
  43.  * definitions extracted
  44.  */
  45.  
  46.   public void addFromMibDefFile(String fileName) 
  47.       throws FileNotFoundException, SnmpMibException {
  48.       BufferedInputStream input 
  49.           = new BufferedInputStream(new FileInputStream(fileName));
  50.       Parser parser = new Parser();
  51.       parser.setMibManager(this);
  52.       parser.setInputStream(input);
  53.       try {
  54.           parser.parse();
  55.       } catch (Exception e) {
  56.           e.printStackTrace();
  57.           throw new SnmpMibException(e.getMessage());
  58.       }
  59.       return;
  60.   }
  61.  
  62. /**
  63.  * Test harness
  64.  */
  65.     
  66.   public static void main(String args[]) {
  67.       PrintStream out = System.out;
  68.  
  69.       out.println("Creating SNMP MIB MANAGER");
  70.       MibManagerParser mibs = new MibManagerParser();
  71.  
  72.       out.println("Reading SNMP mib");
  73.       try {
  74.       mibs.addFromMibDefFile("mib1.txt");
  75.       } catch(FileNotFoundException e) {
  76.       out.println("File not found");
  77.       return;
  78.       } catch(Exception e) {
  79.       out.println("Exception");
  80.       e.printStackTrace();
  81.       mibs.dump();
  82.       };
  83.  
  84.       mibs.dump();
  85.   }
  86. }
  87.